﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using BLToolkit.DataAccess;
using BLToolkit.Mapping;

namespace Calendar.Logic.ObjectModel.Authorization
{
    [MetadataType(typeof(User)), MapField("USR_ID", "ID"), MapField("USR_DESC", "DESC"), TableName("USERS")]
    public abstract class User : Entity
    {
        [MapField("USR_LOGIN"), DisplayName(@"Логин"), Required, RegularExpression(@"\w{2,20}")]
        public abstract String Username { get; protected internal set; }

        [MapField("USR_NAME"), DisplayName(@"Имя"), Required]
        public abstract String Name { get; set; }

        [MapField("USR_PATRONYMIC"), DisplayName(@"Отчество")]
        public abstract String Patronymic { get; set; }

        [MapField("USR_FAMILYNAME"), DisplayName(@"Фамилия")]
        public abstract String FamilyName { get; set; }

        [MapField("USR_APPNAME"), DisplayName(@"Название программы"), RegularExpression(".{1,255}")]
        public abstract string ApplicationName { get; protected internal set; }

        [MapField("USR_EMAIL"), DisplayName(@"Email"), Required, RegularExpression(".{1,128}")]
        public abstract string Email { get; set; }

        [MapField("USR_COMMENT"), DisplayName(@"Коментарий"), RegularExpression(".{0,255}")]
        public abstract string Comment { get; set; }

        [MapField("USR_PASSWORD"), DisplayName(@"Пароль"), RegularExpression(".{1,255}")]
        public abstract string Password { get; protected internal set; }

        [MapField("USR_PASSSALT"), RegularExpression(".{1,128}")]
        public abstract string PasswordSalt { get; protected internal set; }

        [MapField("USR_PASSQUEST"), DisplayName(@"Секретный вопрос"), RegularExpression(".{1,255}")]
        public abstract string PasswordQuestion { get; protected internal set; }

        [MapField("USR_PASSANSW"), DisplayName(@"Ответ"), RegularExpression(".{1,255}")]
        public abstract string PasswordAnswer { get; protected internal set; }

        [MapField("USR_APPROVED"), DisplayName(@"Утвержденный")]
        public abstract bool IsApproved { get; set; }

        [MapField("USR_LASTACTIVITY"), DisplayName(@"Дата последней активности")]
        public abstract DateTime LastActivityDate { get; protected internal set; }

        [MapField("USR_LASTLOGIN"), DisplayName(@"Дата последней входа")]
        public abstract DateTime LastLoginDate { get; protected internal set; }

        [MapField("USR_PASSCHANGE"), DisplayName(@"Дата последней смены пароля")]
        public abstract DateTime LastPasswordChangedDate { get; protected internal set; }

        [MapField("USR_CREATED"), DisplayName(@"Дата создания")]
        public abstract DateTime CreationDate { get; protected internal set; }

        [MapField("USR_LOCKED"), DisplayName(@"Блокирован")]
        public abstract bool IsLockedOut { get; set; }

        [MapField("USR_LASTLOCKED"), DisplayName(@"Дата блокировки")]
        public abstract DateTime LastLockedOutDate { get; protected internal set; }

        [MapField("USR_FAILEDCOUNT"), DisplayName(@"Количество попыток ввода пароля")]
        public abstract int FailedPasswordAttemptCount { get; protected internal set; }

        [MapField("USR_FAILEDDATE"), DisplayName(@"Дата неверного ввода пароля")]
        public abstract DateTime FailedPasswordAttemptWindowStart { get; protected internal set; }

        [MapField("USR_FAILEDANSWCOUNT"), DisplayName(@"Количество попыток ввода ответа")]
        public abstract int FailedPasswordAnswerAttemptCount { get; protected internal set; }

        [MapField("USR_FAILEDANSWDATE"), DisplayName(@"Дата неверного ввода ответа")]
        public abstract DateTime FailedPasswordAnswerAttemptWindowStart { get; protected internal set; }
    }
}
